/**
 * Title:       PlatformGUI.java
 * Copyright:   Copyright (c) 1996-2004 The Agent Factory Working Group. All rights reserved.
 * Licence:     This file is free software; you can redistribute it and/or modify
 *              it under the terms of the GNU Lesser General Public License as published by
 *              the Free Software Foundation; either version 2.1, or (at your option)
 *              any later version.
 *
 *              This file is distributed in the hope that it will be useful,
 *              but WITHOUT ANY WARRANTY; without even the implied warranty of
 *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *              GNU Lesser General Public License for more details.
 *
 *              You should have received a copy of the GNU Lesser General Public License
 *              along with Agent Factory; see the file COPYING.  If not, write to
 *              the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *              Boston, MA 02111-1307, USA.
 */
package com.agentfactory.platform.core;

import java.util.ArrayList;


/**
 * Provide a skeleton implementation of an Agent Factory Platform Viewer. Subclasses of {@code PlatformGUI} should
 * provide a public constructor that takes an {@link AgentPlatform} as its only parameter.
 *
 * @author Robert Ross
 */
public abstract class PlatformGUI {
    private ArrayList parameters;

    /**
     * Creates a new PlatformGUI object.
     */
    public PlatformGUI(  ) {}

    /**
     * Startup code for any platform gui should be placed in
     * implementations of this abstract method...
     */
    public abstract void start(  );

    /**
     * Get the parameters that were passed to this {@code PlatformGUI}
     *
     * @return The parameters
     */
    public ArrayList getParameters(  ) {
        if( parameters == null )
            System.err.println( "[PlatformGUI]: Parameters are not loaded when constructor is called - use the start() method" );

        return parameters;
    }

    /**
     * Set the parameters passed to this {@code PlatformGUI}
     *
     * @param parameters The parameters
     */
    public void setParameters( ArrayList parameters ) {
        this.parameters = parameters;
    }

    /**
     * Get the parameter in position {@code index} (starts at 0)
     *
     * @param index The position of the parameter to be returned
     *
     * @return The parameter in position {@code index}
     */
    protected String getParameter( int index ) {
        if( parameters == null )
            System.err.println( "[PlatformGUI]: Parameters are not loaded when constructor is called - use the start() method" );

        return ( String ) parameters.get( index );
    }

    /**
     * Get the number of parameters passed to this {@code PlatformGUI}
     *
     * @return The number of parameters!
     */
    protected int numParameters(  ) {
        if( parameters == null )
            System.err.println( "[PlatformGUI]: Parameters are not loaded when constructor is called - use the start() method" );

        return parameters.size(  );
    }
}